package de.latzko.pattern.math

import scalala.Scalala._;
import scalala.tensor.dense.DenseVector;


trait ScatterPlot {
  def scatterPlot(arr: Array[DenseVector], colors: Array[Int] = new Array[Int](0)) = {

    val n = arr.size;
    var x = DenseVector(n)(0)
    var y = DenseVector(n)(0)

    var s = DenseVector(n)(0.02)
    var c = DenseVector(n)(1)
    if (colors.size == n) {
      val maxC: Double = colors.reduceRight(_ max _)
      for (i <- 0 until n){
        c(i) = colors(i) / maxC
        s(i) = colors(i) / (maxC *10)
        
      }
        
    }
    for (i <- 0 until n) {
      x(i) = arr(i)(0); y(i) = arr(i)(1);

    }

    scatter(x, y, s, c)

  }

  def showHistogram(labels: Array[Int]) {
    val maxLabel = labels.reduceRight(_ max _)+ 1
    var arr = DenseVector(maxLabel)(0)
   	
    labels.foreach(x => arr(x) += 1)
    arr.foreach(x => if(x ==1)println("find 1" + x))
    plot(arr)

  }
}